<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>    
    
<!DOCTYPE html>
<html lang="zh">
<head>
	<meta charset="utf-8">
	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" />
	<title>客户资源管理系统</title>
	<!-- 标签图标设置 -->
	<link rel="icon" href="images/favicon.ico" type="image/ico">
	<!-- SEO（搜索引擎所有关键件） -->
	<meta name="keywords" content="crm,qf">
	<meta name="description" content="这是一个解决中小企业客户资源管理的网站">
	<meta name="author" content="枫桥夜泊1990">
	<link href="css/bootstrap.min.css" rel="stylesheet">
	<link href="css/materialdesignicons.min.css" rel="stylesheet">
	<link href="css/style.min.css" rel="stylesheet">
	<link rel="stylesheet" href="js/jconfirm/jquery-confirm.min.css">
</head>
  
<body>
<div class="lyear-layout-web">
  <div class="lyear-layout-container">
    <!--左侧导航-->
    <aside class="lyear-layout-sidebar">
      
      <!-- logo -->
      <div id="logo" class="sidebar-header">
        <a href="index.html"><img src="images/logo-sidebar.png" title="LightYear" alt="LightYear" /></a>
      </div>
      <div class="lyear-layout-sidebar-scroll"> 
        
        <jsp:include page="common/menus.jsp"></jsp:include>
        
         <div class="sidebar-footer">
		  <p class="copyright">Copyright &copy; 2020. <img style="width: 25px;padding-bottom: 5px;" src="images/fy.png" /> <a target="_blank" href="https://hd1611756908.github.io/"> CRM</a>&nbsp; Powered By &nbsp;<a href="https://space.bilibili.com/514155929/" target="_blank" title="枫桥夜泊">枫桥夜泊</a></p>
		</div>
      </div>
      
    </aside>
    <!--End 左侧导航-->
    
    <!--头部信息-->
    <header class="lyear-layout-header">
      
      <nav class="navbar navbar-default">
        <div class="topbar">
          
          <div class="topbar-left">
            <div class="lyear-aside-toggler">
              <span class="lyear-toggler-bar"></span>
              <span class="lyear-toggler-bar"></span>
              <span class="lyear-toggler-bar"></span>
            </div>
            <span class="navbar-page-title"> 产品 - 产品列表 </span>
          </div>
          
          <ul class="topbar-right">
          
              <jsp:include page="common/ABC.jsp"></jsp:include>
            <!--切换主题配色-->
		    <li class="dropdown dropdown-skin">
			  <span data-toggle="dropdown" class="icon-palette"><i class="mdi mdi-palette"></i></span>
			  <ul class="dropdown-menu dropdown-menu-right" data-stopPropagation="true">
                <li class="drop-title"><p>主题</p></li>
                <li class="drop-skin-li clearfix">
                  <span class="inverse">
                    <input type="radio" name="site_theme" value="default" id="site_theme_1" checked>
                    <label for="site_theme_1"></label>
                  </span>
                  <span>
                    <input type="radio" name="site_theme" value="dark" id="site_theme_2">
                    <label for="site_theme_2"></label>
                  </span>
                  <span>
                    <input type="radio" name="site_theme" value="translucent" id="site_theme_3">
                    <label for="site_theme_3"></label>
                  </span>
                </li>
			    <li class="drop-title"><p>LOGO</p></li>
				<li class="drop-skin-li clearfix">
                  <span class="inverse">
                    <input type="radio" name="logo_bg" value="default" id="logo_bg_1" checked>
                    <label for="logo_bg_1"></label>
                  </span>
                  <span>
                    <input type="radio" name="logo_bg" value="color_2" id="logo_bg_2">
                    <label for="logo_bg_2"></label>
                  </span>
                  <span>
                    <input type="radio" name="logo_bg" value="color_3" id="logo_bg_3">
                    <label for="logo_bg_3"></label>
                  </span>
                  <span>
                    <input type="radio" name="logo_bg" value="color_4" id="logo_bg_4">
                    <label for="logo_bg_4"></label>
                  </span>
                  <span>
                    <input type="radio" name="logo_bg" value="color_5" id="logo_bg_5">
                    <label for="logo_bg_5"></label>
                  </span>
                  <span>
                    <input type="radio" name="logo_bg" value="color_6" id="logo_bg_6">
                    <label for="logo_bg_6"></label>
                  </span>
                  <span>
                    <input type="radio" name="logo_bg" value="color_7" id="logo_bg_7">
                    <label for="logo_bg_7"></label>
                  </span>
                  <span>
                    <input type="radio" name="logo_bg" value="color_8" id="logo_bg_8">
                    <label for="logo_bg_8"></label>
                  </span>
				</li>
				<li class="drop-title"><p>头部</p></li>
				<li class="drop-skin-li clearfix">
                  <span class="inverse">
                    <input type="radio" name="header_bg" value="default" id="header_bg_1" checked>
                    <label for="header_bg_1"></label>                      
                  </span>                                                    
                  <span>                                                     
                    <input type="radio" name="header_bg" value="color_2" id="header_bg_2">
                    <label for="header_bg_2"></label>                      
                  </span>                                                    
                  <span>                                                     
                    <input type="radio" name="header_bg" value="color_3" id="header_bg_3">
                    <label for="header_bg_3"></label>
                  </span>
                  <span>
                    <input type="radio" name="header_bg" value="color_4" id="header_bg_4">
                    <label for="header_bg_4"></label>                      
                  </span>                                                    
                  <span>                                                     
                    <input type="radio" name="header_bg" value="color_5" id="header_bg_5">
                    <label for="header_bg_5"></label>                      
                  </span>                                                    
                  <span>                                                     
                    <input type="radio" name="header_bg" value="color_6" id="header_bg_6">
                    <label for="header_bg_6"></label>                      
                  </span>                                                    
                  <span>                                                     
                    <input type="radio" name="header_bg" value="color_7" id="header_bg_7">
                    <label for="header_bg_7"></label>
                  </span>
                  <span>
                    <input type="radio" name="header_bg" value="color_8" id="header_bg_8">
                    <label for="header_bg_8"></label>
                  </span>
				</li>
				<li class="drop-title"><p>侧边栏</p></li>
				<li class="drop-skin-li clearfix">
                  <span class="inverse">
                    <input type="radio" name="sidebar_bg" value="default" id="sidebar_bg_1" checked>
                    <label for="sidebar_bg_1"></label>
                  </span>
                  <span>
                    <input type="radio" name="sidebar_bg" value="color_2" id="sidebar_bg_2">
                    <label for="sidebar_bg_2"></label>
                  </span>
                  <span>
                    <input type="radio" name="sidebar_bg" value="color_3" id="sidebar_bg_3">
                    <label for="sidebar_bg_3"></label>
                  </span>
                  <span>
                    <input type="radio" name="sidebar_bg" value="color_4" id="sidebar_bg_4">
                    <label for="sidebar_bg_4"></label>
                  </span>
                  <span>
                    <input type="radio" name="sidebar_bg" value="color_5" id="sidebar_bg_5">
                    <label for="sidebar_bg_5"></label>
                  </span>
                  <span>
                    <input type="radio" name="sidebar_bg" value="color_6" id="sidebar_bg_6">
                    <label for="sidebar_bg_6"></label>
                  </span>
                  <span>
                    <input type="radio" name="sidebar_bg" value="color_7" id="sidebar_bg_7">
                    <label for="sidebar_bg_7"></label>
                  </span>
                  <span>
                    <input type="radio" name="sidebar_bg" value="color_8" id="sidebar_bg_8">
                    <label for="sidebar_bg_8"></label>
                  </span>
				</li>
			  </ul>
			</li>
            <!--切换主题配色-->
          </ul>
          
        </div>
      </nav>
      
    </header>
    <!--End 头部信息-->
    
    <!--页面主要内容-->
    <main class="lyear-layout-content">
      
      <div class="container-fluid">
        
        
        <div class="row">
		  <div class="col-lg-12">
			<div class="card">
			  <div class="card-toolbar clearfix">
			  
				<form class="pull-right search-bar" method="get" action="#!" role="form">
				
				
				  <div class="input-group">
					<input type="text" class="form-control" value="" name="keyword" placeholder="请输入产品名称">
					
					<div class="input-group-btn">
					  <button class="btn btn-dark" type="button">搜索</button>
					</div>
					
				  </div>

				  
				</form>
				
				<div class="toolbar-btn-action">
				  <a class="btn btn-primary m-r-5" href="${pageContext.request.contextPath }/ThreadAddJumpServlet"><i class="mdi mdi-plus"></i> 新增</a>
	
				  <a id="btnDel" class="btn btn-danger" href="#!"><i class="mdi mdi-window-close"></i> 删除</a>
				</div>
			  </div>
			  <div class="card-body">
				
				<div class="table-responsive">
				  <table class="table table-hover">
					<thead>
					  <tr>
						<th>
						  <label class="lyear-checkbox checkbox-primary">
							<input type="checkbox"  id="check-all"><span></span>
						  </label>
						</th>
                        <th>线索人名称</th>
						<th>手机</th>
						<th>负责人</th>
						<th>创建人</th>
						<th>线索来源</th>
						<th>客户行业</th>
						<th>客户级别</th>
						<th>创建时间</th>
						<th>更新时间</th>
						<th>下次联系时间</th>
						<th>操作</th>
					  </tr>
					</thead>  
					
					                                             <!--内容区  -->
					<tbody id="customer_tbody">
					  <!-- <tr>
						<td>
						  <label class="lyear-checkbox checkbox-primary">
							<input type="checkbox"  name="ids[]" value="1001"><span></span>
						  </label>
						</td>
						<td>华为p30</td>
						<td>10001</td>
						<td>手机</td>
						<td>1000</td>
						<td>李雷</td>
						<td>2012-12-12</td>
						<td>2012-12-12</td>
						<td>上架</td>
						<td>
						  <div class="btn-group">
							<a class="btn btn-xs btn-default" href="thread_update.html" title="编辑" data-toggle="tooltip"><i class="mdi mdi-pencil"></i></a>
							<a class="btn btn-xs btn-default" href="#!" title="删除" data-toggle="tooltip"><i class="mdi mdi-window-close"></i></a>
						  </div>
						</td>
					  </tr> -->
					  
					  
<!-- 					  <tr>
						<td>
						  <label class="lyear-checkbox checkbox-primary">
							<input type="checkbox" name="ids[]" value="1001"><span></span>
						  </label>
						</td>
						<td>华为p30</td>
						<td>10001</td>
						<td>手机</td>
						<td>1000</td>
						<td>李雷</td>
						<td>2012-12-12</td>
						<td>2012-12-12</td>
						<td>下架</td>
						<td>
						  <div class="btn-group">
							<a class="btn btn-xs btn-default" href="thread_update.html" title="编辑" data-toggle="tooltip"><i class="mdi mdi-pencil"></i></a>
							<a class="btn btn-xs btn-default" href="#!" title="删除" data-toggle="tooltip"><i class="mdi mdi-window-close"></i></a>
						  </div>
						</td>
					  </tr> -->
					  
					  
					  
					</tbody>
				  </table>
				</div>
				
				<ul class="pagination">
				
<!-- 				  <li class="disabled"><span>«</span></li>
				  <li class="active"><span>1</span></li>
				  <li><a href="#1">2</a></li>
				  <li><a href="#1">3</a></li>
				  <li><a href="#1">4</a></li>
				  <li><a href="#!">»</a></li> -->
				  
				  
				</ul>
	   
			  </div>
			</div>
		  </div>
		  
		</div>
       
     
        
      </div>
      
    </main>
    <!--End 页面主要内容-->
  </div>
</div>

<script type="text/javascript" src="js/jquery.min.js"></script>
<script type="text/javascript" src="js/bootstrap.min.js"></script>
<script type="text/javascript" src="js/perfect-scrollbar.min.js"></script>
<script type="text/javascript" src="js/main.min.js"></script>
<!--图表插件-->
<script type="text/javascript" src="js/Chart.js"></script>
<script src="js/jconfirm/jquery-confirm.min.js"></script>
<script type="text/javascript">
	
	$(function(){
		
	
	    var customerID = null;
		
	    var arr = [];
	    
	    /*      导出     */
		$('#downLoad').on('click', function () {
			
			/* 			var arr3=new Array(10);  */ 
						//获取被选中的多选框
						
						var cks = $("input[type='checkbox']:checked").not($("#check-all"));
						
						for(var i=0;i<cks.length;i++){
							console.log(cks[i].value);	
						}
						
					    $.confirm({
					        title: '导出',
					        content: '是否确认导出?',
					        type: 'green',
					        typeAnimated: true,
					        buttons: {
					            tryAgain: {
					                text: '确认',
					                btnClass: 'btn-red',
					                action: function(){
					                	
										//当点击确认删除时被执行
										console.log('确认导出....');	
				                    
										for(var i=0;i<cks.length;i++){
											
											arr[i]=cks[i].value;
											
											console.log(arr[i]);
											
										}
										
										 $.ajax({
									            type: "post", 
									            url:"ProductDownLoadExcelServlet",
									            data: {"arr":arr},
									            dataType:"json", 
									            success:function(d){
									              
									            },
										            traditional :true,//阻止jq的深度序列化 
										            error:function(data){          
									            }
									            
									            }); 
													
										
						
					                }
					            },
					            close: {
					                text: '关闭'
					            }
					        }
					    });
					});
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		/* 删除提示框生成 */
		
		$('#btnDel').on('click', function () {
			
/* 			var arr3=new Array(10);  */ 
			//获取被选中的多选框
			
			var cks = $("input[type='checkbox']:checked").not($("#check-all"));
			
			for(var i=0;i<cks.length;i++){
				console.log(cks[i].value);	
			}
			
		    $.confirm({
		        title: '删除',
		        content: '是否确认删除?',
		        type: 'red',
		        typeAnimated: true,
		        buttons: {
		            tryAgain: {
		                text: '确认',
		                btnClass: 'btn-red',
		                action: function(){
							//当点击确认删除时被执行
							console.log('确认删除....');
							
	/*  */	
	                    
							for(var i=0;i<cks.length;i++){
								
								customerID =cks[i].value;
								
								console.log(customerID );
								
								$.getJSON("${pageContext.request.contextPath }/ThreadDelectJsonServlet",{customerID:customerID},function(d){					
									console.log("d=",d);
									  if(d.code == 200){
										  //删除成功    跳转到  列表    
										  window.location.href="thread_list.jsp";
									  }

									 /* window.location.href="book_list.jsp"; */
		
								});	
										
							}
			
		                }
		            },
		            close: {
		                text: '关闭'
		            }
		        }
		    });
		});
		
		
		
	});
	
	
	
	
	//  使用 AJAX 分页数据 
	var pageNO = 1;
	var pageSize = 3;
	var pageCount = null;

	$.getJSON("${pageContext.request.contextPath }/ThreadListServlet",{pageNO:pageNO,pageSize:pageSize},function(d){
		
/*   	console.log(d);         */
		
		pageCount = d.pageCount;
		
/* 		console.log(pageCount);      "+d.object[i].+"            */
		
		var str="";                                         
		for(var i=0;i<d.object.length;i++){
			
			str+="					  <tr>\r\n" + 
			"						<td>\r\n" + 
			"						  <label class=\"lyear-checkbox checkbox-primary\">\r\n" + 
			"							<input type=\"checkbox\" name=\"ids[]\" value="+d.object[i].customerID+"><span></span>\r\n" + 
			"						  </label>\r\n" + 
			"						</td>\r\n" + 
			"						<td>"+d.object[i].customerName+"</td>\r\n" + 
			"						<td>"+d.object[i].phone+"</td>\r\n" + 
			"						<td>"+d.object[i].personLiable.employeeName+"</td>\r\n" + 
			"						<td>"+d.object[i].founder.employeeName+"</td>\r\n" + 
			"						<td>"+d.object[i].sources.sourceName+"</td>\r\n" + 
			"						<td>"+d.object[i].industry.industryName+"</td>\r\n" + 
			"						<td>"+d.object[i].level.levelName+"</td>\r\n" + 
			"						<td>"+d.object[i].createTime+"</td>\r\n" + 
			"						<td>"+d.object[i].updateTime+"</td>\r\n" + 
			"						<td>"+d.object[i].nextContactTime+"</td>\r\n" + 
			"						<td>\r\n" + 
			"						  <div class=\"btn-group\">\r\n" + 
			"							<a class=\"btn btn-xs btn-default\" href=\"${pageContext.request.contextPath}/ThreadUpdateJumpServlet?customerID="+d.object[i].customerID+"\" title=\"编辑\" data-toggle=\"tooltip\"><i class=\"mdi mdi-pencil\"></i></a>\r\n" + 
			"							<a class=\"btn btn-xs btn-default\" href=\"${pageContext.request.contextPath}/ThreadDeleteServlet?customerID="+d.object[i].customerID+"\" title=\"删除\" data-toggle=\"tooltip\"><i class=\"mdi mdi-window-close\"></i></a>\r\n" + 
			"						  </div>\r\n" + 
			"						</td>\r\n" + 
			"					  </tr>";
			
			
		}
		
	    $("#customer_tbody").html(str);
	    
	    joinPage(pageNO,pageCount);
		
	    currentPage(pageNO,".currentPage");
	    
	    bindPage(pageNO,pageSize)
	    
	    
	/*                         选框                     */
	
	var $items = $("input[name='ids[]']");
	console.log($items);
	// 全选框     
	var checkAllBtn = ($("#check-all"));

	// 判断 全选和全不部选
	for (var i = 0; i < $items.length; i++) {
		$($items[i]).click(function(){

				//默认全给选中
				checkAllBtn[0].checked = true;
				//如果发现有一个没选中,取消全选
				for (var j = 0; j < $items.length; j++) {
					if (!$items[j].checked) {                    /* 当发现有一个时 false 执行 if 判断语句   将全选款 checked = false  */
						checkAllBtn[0].checked = false;
						break;
					}
				}
			});
		}
	    
	    
  
	    
	});
	
	
	
	
	
	function bindPage(pageNO,pageSize){
		 
		 
		 
		 // 绑定中间页
		 
		 var cps=$(".currentPage");
		
		 for(var i=0;i<cps.length;i++){
			 $(cps[i]).click(function(){
				 pageNO=parseInt(this.innerHTML);
				 
				 
				 
				 
				 
				 $.getJSON("${pageContext.request.contextPath }/ThreadListServlet",{pageNO:pageNO,pageSize:pageSize},function(d){
						
					 /*   	console.log(d);         */
					 		
					 		pageCount = d.pageCount;
					 		
					 /* 		console.log(pageCount);      "+d.object[i].+"            */
					 		
					 		var str="";                                         
					 		for(var i=0;i<d.object.length;i++){
					 			
					 			str+="					  <tr>\r\n" + 
					 			"						<td>\r\n" + 
					 			"						  <label class=\"lyear-checkbox checkbox-primary\">\r\n" + 
					 			"							<input type=\"checkbox\" name=\"ids[]\" value="+d.object[i].customerID+"><span></span>\r\n" + 
					 			"						  </label>\r\n" + 
					 			"						</td>\r\n" + 
					 			"						<td>"+d.object[i].customerName+"</td>\r\n" + 
					 			"						<td>"+d.object[i].phone+"</td>\r\n" + 
					 			"						<td>"+d.object[i].personLiable.employeeName+"</td>\r\n" + 
					 			"						<td>"+d.object[i].founder.employeeName+"</td>\r\n" + 
					 			"						<td>"+d.object[i].sources.sourceName+"</td>\r\n" + 
					 			"						<td>"+d.object[i].industry.industryName+"</td>\r\n" + 
					 			"						<td>"+d.object[i].level.levelName+"</td>\r\n" + 
					 			"						<td>"+d.object[i].createTime+"</td>\r\n" + 
					 			"						<td>"+d.object[i].updateTime+"</td>\r\n" + 
					 			"						<td>"+d.object[i].nextContactTime+"</td>\r\n" + 
					 			"						<td>\r\n" + 
					 			"						  <div class=\"btn-group\">\r\n" + 
					 			"							<a class=\"btn btn-xs btn-default\" href=\"${pageContext.request.contextPath}/CustomerUpdateJumpServlet?customerID="+d.object[i].customerID+"\" title=\"编辑\" data-toggle=\"tooltip\"><i class=\"mdi mdi-pencil\"></i></a>\r\n" + 
					 			"							<a class=\"btn btn-xs btn-default\" href=\"${pageContext.request.contextPath}/CustomerDeleteServlet?customerID="+d.object[i].customerID+"\" title=\"删除\" data-toggle=\"tooltip\"><i class=\"mdi mdi-window-close\"></i></a>\r\n" + 
					 			"						  </div>\r\n" + 
					 			"						</td>\r\n" + 
					 			"					  </tr>";
					 			
					 			
					 		}
					 		
					 	    $("#customer_tbody").html(str);
					 	    
					 	    joinPage(pageNO,pageCount);
					 		
					 	    currentPage(pageNO,".currentPage");
					 	    
					 	    bindPage(pageNO,pageSize)
							    
							});
				 
				 
			 });
			 
			 
		 }
		 
		 
		 
		 
		 
		//  绑定上一页	 
		$("#pre").click(function(){
			
			if(pageNO<=1){
				
				alert("已经是最后一页了");
				
			}else{
				pageNO=pageNO-1;
				
				
				
				$.getJSON("${pageContext.request.contextPath }/ThreadListServlet",{pageNO:pageNO,pageSize:pageSize},function(d){
					
					/*   	console.log(d);         */
							
							pageCount = d.pageCount;
							
					/* 		console.log(pageCount);      "+d.object[i].+"            */
							
							var str="";                                         
							for(var i=0;i<d.object.length;i++){
								
								str+="					  <tr>\r\n" + 
								"						<td>\r\n" + 
								"						  <label class=\"lyear-checkbox checkbox-primary\">\r\n" + 
								"							<input type=\"checkbox\" name=\"ids[]\" value="+d.object[i].customerID+"><span></span>\r\n" + 
								"						  </label>\r\n" + 
								"						</td>\r\n" + 
								"						<td>"+d.object[i].customerName+"</td>\r\n" + 
								"						<td>"+d.object[i].phone+"</td>\r\n" + 
								"						<td>"+d.object[i].personLiable.employeeName+"</td>\r\n" + 
								"						<td>"+d.object[i].founder.employeeName+"</td>\r\n" + 
								"						<td>"+d.object[i].sources.sourceName+"</td>\r\n" + 
								"						<td>"+d.object[i].industry.industryName+"</td>\r\n" + 
								"						<td>"+d.object[i].level.levelName+"</td>\r\n" + 
								"						<td>"+d.object[i].createTime+"</td>\r\n" + 
								"						<td>"+d.object[i].updateTime+"</td>\r\n" + 
								"						<td>"+d.object[i].nextContactTime+"</td>\r\n" + 
								"						<td>\r\n" + 
								"						  <div class=\"btn-group\">\r\n" + 
								"							<a class=\"btn btn-xs btn-default\" href=\"${pageContext.request.contextPath}/CustomerUpdateJumpServlet?customerID="+d.object[i].customerID+"\" title=\"编辑\" data-toggle=\"tooltip\"><i class=\"mdi mdi-pencil\"></i></a>\r\n" + 
								"							<a class=\"btn btn-xs btn-default\" href=\"${pageContext.request.contextPath}/CustomerDeleteServlet?customerID="+d.object[i].customerID+"\" title=\"删除\" data-toggle=\"tooltip\"><i class=\"mdi mdi-window-close\"></i></a>\r\n" + 
								"						  </div>\r\n" + 
								"						</td>\r\n" + 
								"					  </tr>";
								
								
							}
							
						    $("#customer_tbody").html(str);
						    
						    joinPage(pageNO,pageCount);
							
						    currentPage(pageNO,".currentPage");
						    
						    bindPage(pageNO,pageSize)
						    
						}); 
				
				
				
			}
	
		});	 
		 
		 
	 
	 //  绑定下一页
	 $("#next").click(function(){
		 
		 if(pageNO>=pageCount){
			 
			 alert("已经是最后一页了");
			 
		 }else{
			 
			 pageNO=pageNO+1;
			 
			 $.getJSON("${pageContext.request.contextPath }/ThreadListServlet",{pageNO:pageNO,pageSize:pageSize},function(d){
					
				 /*   	console.log(d);         */
				 		
				 		pageCount = d.pageCount;
				 		
				 /* 		console.log(pageCount);      "+d.object[i].+"            */
				 		
				 		var str="";                                         
				 		for(var i=0;i<d.object.length;i++){
				 			
				 			str+="					  <tr>\r\n" + 
				 			"						<td>\r\n" + 
				 			"						  <label class=\"lyear-checkbox checkbox-primary\">\r\n" + 
				 			"							<input type=\"checkbox\" name=\"ids[]\" value="+d.object[i].customerID+"><span></span>\r\n" + 
				 			"						  </label>\r\n" + 
				 			"						</td>\r\n" + 
				 			"						<td>"+d.object[i].customerName+"</td>\r\n" + 
				 			"						<td>"+d.object[i].phone+"</td>\r\n" + 
				 			"						<td>"+d.object[i].personLiable.employeeName+"</td>\r\n" + 
				 			"						<td>"+d.object[i].founder.employeeName+"</td>\r\n" + 
				 			"						<td>"+d.object[i].sources.sourceName+"</td>\r\n" + 
				 			"						<td>"+d.object[i].industry.industryName+"</td>\r\n" + 
				 			"						<td>"+d.object[i].level.levelName+"</td>\r\n" + 
				 			"						<td>"+d.object[i].createTime+"</td>\r\n" + 
				 			"						<td>"+d.object[i].updateTime+"</td>\r\n" + 
				 			"						<td>"+d.object[i].nextContactTime+"</td>\r\n" + 
				 			"						<td>\r\n" + 
				 			"						  <div class=\"btn-group\">\r\n" + 
				 			"							<a class=\"btn btn-xs btn-default\" href=\"${pageContext.request.contextPath}/CustomerUpdateJumpServlet?customerID="+d.object[i].customerID+"\" title=\"编辑\" data-toggle=\"tooltip\"><i class=\"mdi mdi-pencil\"></i></a>\r\n" + 
				 			"							<a class=\"btn btn-xs btn-default\" href=\"${pageContext.request.contextPath}/CustomerDeleteServlet?customerID="+d.object[i].customerID+"\" title=\"删除\" data-toggle=\"tooltip\"><i class=\"mdi mdi-window-close\"></i></a>\r\n" + 
				 			"						  </div>\r\n" + 
				 			"						</td>\r\n" + 
				 			"					  </tr>";
				 			
				 			
				 		}
				 		
				 	    $("#customer_tbody").html(str);
				 	    
				 	    joinPage(pageNO,pageCount);
				 		
				 	    currentPage(pageNO,".currentPage");
				 	    
				 	    bindPage(pageNO,pageSize)
						    
						}); 
			 
			 
			 
			 
		 }

	 });
		 
	 
}
	
	
	
	
	// 当前页的颜色
	function currentPage(pageNO,currentPage){
		
		var c =$(currentPage);
		
		 for(var i=0;i<c.length;i++){
			 var cp=c[i].innerHTML;              /* innerHTML  拿到当前页码 */
			 if(pageNO==cp){                              /* 如果当前页  比较 如果是当前页  就添加样式         */
				// c[i].style.cssText="color:red";
				 c[i].style.cssText="color:red";         
			 }		 
		 }
		
	}
	
	
	// 显示页
	function joinPage(pageNO,pageCount){
		
		//  上一页
		var str="<li><span id='pre'>«</span></li>";
		
		if(pageCount<=3){
			for(var i=1;i<=pageCount;i++){
				str += "<li><a class='currentPage' href=\"#1\">"+i+"</a></li>";
			}
		}else{
			if(pageNO<=3){
				for(var i=1;i<=3;i++){
					str +="<li><a class='currentPage' href=\"#1\">"+i+"</a></li>";
				}
			}else{
				for(var i=pageNO-2;i<=pageNO;i++){
					str +="<li><a class='currentPage' href=\"#1\">"+i+"</a></li>";
				}
			}
		}
		
		// 下一页
		str +="<li><span id='next'>»</span></li>";  
		
		$(".pagination").html(str);
	}
	
	
	
	
	
	
	
	
</script>
</body>
</html>    